#include <iostream>
#include<cstring>
using namespace std;
#define MAXN 100
int edge[MAXN][MAXN];
int od[MAXN];
int id[MAXN];
int main(void) 
{
	int n,m;
	while(cin>>n>>m&&(n!=0&&m!=0)){
		memset(edge,0,sizeof(edge));
		memset(od,0,sizeof(od));
		memset(id,0,sizeof(id));
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			edge[x][y]=1;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				od[i]+=edge[i][j];
				id[i]+=edge[j][i];
			}
		}
		
		for(int i=1;i<=n;i++){
			cout<<od[i]<<" ";
		}
		cout<<endl;
		for(int i=1;i<=n;i++){
			cout<<id[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
	
}
